home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / comm / udecodbs.1 < prev    next >
Internet Message Format  |  1989-04-29  |  3KB

  1. Path: xanth!nic.MR.NET!indri!lll-winken!ames!oliveb!sun!rishathra!page
  2. From: page%rishathra@Sun.COM (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i109:  uudecode-bas - amigabasic version of uudecode
  5. Message-ID: <101954@sun.Eng.Sun.COM>
  6. Date: 29 Apr 89 03:08:36 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 78
  9. Approved: page@sun.com
  10.  
  11. Submitted-by: creutz@bnlux0.bnl.gov (Michael Creutz)
  12. Posting-number: Volume 89, Issue 109
  13. Archive-name: comm/uudecode-bas.1
  14.  
  15. [You can use this to bootstap yourself -- uudecode the fast uudecode
  16. program previously posted to comp.binaries.amiga and use that instead;
  17. that one is faster, has error detection and even some correction
  18. capability.  Many thanks to Michael for providing this one.  ..bob]
  19.  
  20. # This is a shell archive.
  21. # Remove anything above and including the cut line.
  22. # Then run the rest of the file through 'sh'.
  23. # Unpacked files will be owned by you and have default permissions.
  24. #----cut here-----cut here-----cut here-----cut here----#
  25. #!/bin/sh
  26. # shar: SHell ARchive
  27. # Run the following text through 'sh' to create:
  28. #    uudecode.bas
  29. # This is archive 1 of a 1-part kit.
  30. # This archive created: Fri Apr 28 20:01:20 1989
  31. echo "extracting uudecode.bas"
  32. sed 's/^X//' << \SHAR_EOF > uudecode.bas
  33. X'This Amiga Basic program uudecodes
  34. X'files. It may not be fast, but it
  35. X'works!  (I have an analogous uuencode
  36. X'program if anyone wants it.)
  37. X
  38. X'    Michael Creutz
  39. X'    creutz@bnlux0.bnl.gov     
  40. X
  41. XWINDOW 1,,(20,20)-(400,150)
  42. XDEFINT a-z
  43. XINPUT "File to decode:",f1$
  44. XINPUT "Decoded file name:",f2$
  45. XOPEN f1$ FOR INPUT AS #1
  46. XOPEN f2$ FOR OUTPUT AS #2
  47. Xlength!=LOF(1)
  48. Xleftlength!=length!
  49. XPRINT "Looking for 'begin.'"
  50. Xfindbegin:
  51. X  IF EOF(1) THEN PRINT "begin not found":CLOSE:END
  52. X  LINE INPUT #1, a$:leftlength!=leftlength!-LEN(a$)-1
  53. X  IF LEFT$(a$,6)<>"begin " THEN GOTO findbegin
  54. X  PRINT
  55. X  PRINT "'begin' found"
  56. X  PRINT "decoding ";f1$;" to file ";f2$
  57. Xnewline:
  58. X  LOCATE 10,10
  59. X  partdone=100*(1!-leftlength!/length!)
  60. X  PRINT partdone;"% finished"
  61. Xinline:  LINE INPUT #1,a$ :leftlength!=leftlength!-LEN(a$)-1
  62. X  IF a$="" THEN GOTO inline
  63. X  IF a$="end" THEN GOTO done
  64. X  count=(ASC(LEFT$(a$,1))-32) AND 63
  65. X  IF count=0 THEN GOTO done
  66. X  pointer=2
  67. X  out$=""
  68. Xloop:
  69. X  a1=(ASC(MID$(a$,pointer  ,1))-32) AND 63
  70. X  a2=(ASC(MID$(a$,pointer+1,1))-32) AND 63
  71. X  a3=(ASC(MID$(a$,pointer+2,1))-32) AND 63
  72. X  a4=(ASC(MID$(a$,pointer+3,1))-32) AND 63
  73. Xpointer=pointer+4
  74. Xcount=count-3
  75. X  out$=out$+CHR$((a1* 4+a2\16) AND 255)
  76. X  out$=out$+CHR$((a2*16+a3\ 4) AND 255)
  77. X  out$=out$+CHR$((a3*64+a4   ) AND 255)
  78. XIF count>0 THEN GOTO loop
  79. X  PRINT #2, out$;
  80. XIF NOT EOF(1) THEN GOTO newline
  81. X  PRINT "end not found"
  82. Xdone:
  83. X  PRINT "all done"
  84. X  CLOSE
  85. SHAR_EOF
  86. echo "End of archive 1 (of 1)"
  87. # if you want to concatenate archives, remove anything after this line
  88. exit
  89.